package com.atguigu.biliplayer.utils;

import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;

/**
 * OkHttp的管理类
 * Created by 刘晨龙 on 2015/11/5.
 */
public class OkHttpMananger {
    private static OkHttpMananger ourInstance = new OkHttpMananger();
    private final OkHttpClient okHttpClient;
    private Request request;

    public static OkHttpMananger getInstance() {
        return ourInstance;
    }

    private OkHttpMananger() {
        okHttpClient = new OkHttpClient();
    }

    /**
     *
     * @param url
     * @param callback
     */
    public void getAsyn(String url,Callback callback){
        if(url == null){
            throw new RuntimeException("请求的url为空");
        }
        request = new Request.Builder().url(url).build();
        okHttpClient.newCall(request).enqueue(callback);
    }

}
